<?php
include 'conn.php';

// 获取用户提交的留言内容
$sendname = $_POST['sendname'];
$content = $_POST['content'];
$created_at = time();
// 将留言插入数据库
$sql = "INSERT INTO messages (sendname,content, created_at) VALUES ('$sendname','$content',$created_at )";
if (mysqli_query($conn, $sql)) {
    echo '留言添加成功,返回<a href="index.php">首页</a>';
} else {
    echo '留言添加失败: ' . mysqli_error($conn);
}

// 关闭数据库连接
mysqli_close($conn);
